package org.xq.shop.maxaishop.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.xq.shop.maxaishop.dao.XqCommodityDao;
import org.xq.shop.maxaishop.entity.XqCommodity;
import org.xq.shop.maxaishop.service.XqCommodityService;

import javax.annotation.Resource;
import java.util.List;

/**
 * (XqCommodity)表服务实现类
 *
 * @author makejava
 * @since 2021-06-11 15:53:11
 */
@Slf4j
@Service("xqCommodityService")
public class XqCommodityServiceImpl implements XqCommodityService {
    @Resource
    private XqCommodityDao xqCommodityDao;

    /**
     * 通过ID查询单条数据
     *
     * @param cid 主键
     * @return 实例对象
     */
    @Override
    public XqCommodity queryById(Integer cid) {
        log.error("cid=" + cid + ", xqCommodityDao == " + xqCommodityDao);
        return this.xqCommodityDao.queryById(cid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<XqCommodity> queryAllByLimit(int offset, int limit) {
        return this.xqCommodityDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<XqCommodity> selectAll() {
        return this.xqCommodityDao.selectAll();
    }

    @Override
    public List<XqCommodity> queryFruit(Integer start,Integer end) {
        return this.xqCommodityDao.queryFruit(start,end);
    }

    @Override
    public List<XqCommodity> selectFruitSales() {
        return this.xqCommodityDao.selectFruitSales();
    }

    @Override
    public List<XqCommodity> selectByUname(String sname, Integer start, Integer end) {
        return this.xqCommodityDao.selectByUname(sname,start,end);
    }


    /**
     * 新增数据
     *
     * @param xqCommodity 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(XqCommodity xqCommodity) {
        return  this.xqCommodityDao.insert(xqCommodity);
    }

    @Override
    public List<XqCommodity> selectVegetableSales() {
        return this.xqCommodityDao.selectVegetableSales();
    }

    /**
     * 修改数据
     *
     * @param xqCommodity 实例对象
     * @return 实例对象
     */
    @Override
    public int update(@RequestBody XqCommodity xqCommodity) {
        return  this.xqCommodityDao.update(xqCommodity);
    }

    /**
     * 通过主键删除数据
     *
     * @param cid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer cid) {
        return this.xqCommodityDao.deleteById(cid) > 0;
    }


    @Override
    public int selectCount() {
        return this.xqCommodityDao.selectCount();
    }

    @Override
    public int insert1(String aname, String comImg) {
        return this.xqCommodityDao.insert1(aname,comImg);
    }

    @Override
    public int updateSales(int sales,int stork,int cid) {
        return this.xqCommodityDao.updateSales(sales,stork,cid);
    }

    @Override
    public int updateStatus(Integer cid) {
        return this.xqCommodityDao.updateStatus(cid);
    }

    @Override
    public List<XqCommodity> queryXjFruit(Integer start, Integer end) {
        return this.xqCommodityDao.queryXjFruit(start,end);
    }

    @Override
    public List<XqCommodity> selectByXjUname(String uname, Integer start, Integer end) {
        return this.xqCommodityDao.selectByXjUname(uname,start,end);
    }

    @Override
    public int selectXjCount() {
        return this.xqCommodityDao.selectXjCount();
    }

    @Override
    public int updateCount(int kc,int cid) {
        return this.xqCommodityDao.updateCount(kc,cid);
    }

    @Override
    public int uopdateStork(int jk, int cid) {
        return this.xqCommodityDao.uopdateStork(jk,cid);
    }


}
